package org.subside.Study.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private MyInterceptor myInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册自定义拦截器，并指定拦截的路径
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**","/login/**/*","/register/**/*");
        //拦截器可以注册多个，路径也可以添加多个，针对不同类型的，添加访问路径
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**","/login/**/*","/register/**/*");
//        registry.addInterceptor(myInterceptor).addPathPatterns("/api/**");
//        registry.addInterceptor(myInterceptor).addPathPatterns("/subside-admin/**");
    }

//    @Bean
//    public MyInterceptor myInterceptor(){
//        return new MyInterceptor();
//    }
}



